package com.mmall.concurrence.future;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.*;

@Slf4j
public class FutureExample1 {


    static class MyCallable implements Callable<String>{

        @Override
        public String call() throws Exception {
            log.info("do SomeThing in callable");
            Thread.sleep(1000);
            return "Done123";
        }
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {


        ExecutorService executorService = Executors.newCachedThreadPool();
        Future<String> stringFuture = executorService.submit(new MyCallable());
        String s = stringFuture.get();
        log.info(s);
    }
}
